package com.oly.cms.general.taglib;

import java.util.List;

import com.oly.cms.general.model.po.WebCat;
import com.oly.cms.general.service.cache.WebCategoryCacheService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 分类标签
 */
@Service("categoryTag")
public class CategoryTag {

    @Autowired
    private WebCategoryCacheService catCacheService;

    /**
     * 分类树
     * 
     * @param catId
     * @return
     */
    public WebCat getCatTreeById(Long catId, String themeName) {
        return catCacheService.listWebCatsTreeById(catId, themeName);
    }

    /**
     * 获取分类
     * 
     * @param catId
     * @return
     */
    public WebCat getCatById(Long catId) {
        return catCacheService.getWebCatByCatId(catId);
    }

    /**
     * 通过分类id获取分类列表 包含自己及后代节点
     * 
     * @param catId
     * @param themeName 主题名字
     * @return
     */
    public List<WebCat> listCategoryByCatId(Long catId, String themeName) {
        return catCacheService.listWebCatsById(catId, themeName);
    }

    /**
     * 儿子节点
     * 
     * @param catId
     * @param themeName 主题名字
     * @return
     */
    public List<WebCat> listCategoryByParentId(Long parentId, String themeName) {
        return catCacheService.listWebCatsByParentId(parentId, themeName);
    }

    /**
     * 
     * @param catType 类型
     * @param catId   分类Id
     * @return
     */
    public List<WebCat> listCategoryByType(Integer catType, Long catId) {
        return catCacheService.listWebCatsByType(catType, catId);
    }

    /**
     * 
     * @param Visible   状态 1|2
     * @param catId     分类Id
     * @param themeName 主题名字
     * @return
     */
    public List<WebCat> listCategoryByVisible(Integer visible, Long catId, String themeName) {
        return catCacheService.listWebCatsByVisible(visible, catId, themeName);
    }

    /**
     * 
     * @param Visible   状态 1|2
     * @param catId     分类Id
     * @param themeName 主题名字
     * @return
     */
    public List<WebCat> listCategoryByVisible(Integer visible, Long catId) {
        return catCacheService.listWebCatsByVisible(visible, catId, null);
    }

}
